//
//  MaterialView.m
//  
//
//  Created by chris on 15/12/26.
//
//

#import "MaterialView.h"

@implementation MaterialView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        self.backgroundColor = [UIColor whiteColor];
        _titleLa = [[UILabel alloc]initWithFrame:CGRectMake1(10, 10,80, 15)];
        //            titleLa.backgroundColor = [UIColor redColor];
        _titleLa.textColor = [UIColor blackColor];
        _titleLa.font = font(15);
//        _titleLa.text = @"物料信息：";
        [self addSubview:_titleLa];
        
        UIImageView * line = [[UIImageView alloc]initWithFrame:CGRectMake1(10, 35, 300, 1)];
        line.backgroundColor = [UIColor colorWithRed:0.89 green:0.89 blue:0.89 alpha:1];
        [self addSubview:line];
        
        for (int i = 0; i < 2; i++)
        {
            UIImageView * line = [[UIImageView alloc]initWithFrame:CGRectMake1(10, 36+54/2*i, 300, 1)];
            if (i == 1)
            {
                line.frame = CGRectMake1(10, 36+20, 300, 1);
            }
            line.backgroundColor = [UIColor colorWithRed:0.69 green:0.78 blue:0.93 alpha:1];
            [self addSubview:line];
        }
        NSArray * titles = @[@"类别",@"申请数目",@"实发数目",@"备注"];
        for (int i = 0; i < 5; i++)
        {
            UIImageView * line = [[UIImageView alloc]initWithFrame:CGRectMake1(10+(300/4)*i, 36, 1, 20)];
            line.backgroundColor = [UIColor colorWithRed:0.69 green:0.78 blue:0.93 alpha:1];
            [self addSubview:line];
            if (i < 4)
            {
                UILabel * titleLa = [[UILabel alloc]initWithFrame:CGRectMake1(11+(300/4)*i,37.5, 300/4-1, 18)];
                titleLa.backgroundColor = [UIColor colorWithRed:0.86 green:0.92 blue:0.97 alpha:1];
                titleLa.textAlignment = NSTextAlignmentCenter;
                titleLa.textColor = [UIColor colorWithRed:0 green:0.63 blue:0.97 alpha:1];
                titleLa.font = font(13);
                titleLa.text = titles[i];
                [self addSubview:titleLa];
            }
            
        }
    }
    return self;
}
CG_INLINE CGRect
CGRectMake1(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
    CGRect rect;
    rect.origin.x = x*ratio_width; rect.origin.y = y*ratio_heigth;
    rect.size.width = width*ratio_width; rect.size.height = height*ratio_heigth;
    return rect;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
